#include<iostream>
#include<cstdio>
using namespace std;
long  n,l,r;long  k;
int main()
{
	freopen("candy.in","r",stdin);	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	k=l%n;
	while((l<=r)&&(k<n)){
		l++;
		k++;
	}
	k--;
	cout<<k;
	fclose(stdin); fclose(stdout);
}
